home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
fgdemo10.zip
/
FUNDMTLS.C
< prev
next >
Wrap
Text File
|
1991-10-05
|
14KB
|
617 lines
/**********************************************************************\
* *
* fundmtls.c -- graphics fundamentals: points, lines, rects, etc. *
* *
\**********************************************************************/
#include "defs.h"
/**********************************************************************\
* *
* do_circles -- draw a bunch of circles *
* *
\**********************************************************************/
do_circles()
{
register int i;
int x1,x2,y1,y2;
/* establish clipping limits */
x1 = 0;
x2 = xlimit;
y1 = menu_bottom;
y2 = ylimit;
fg_setclip(x1,x2,y1,y2);
/* clear bottom part of screen */
fg_mousevis(OFF);
if (mode06 || mode11)
fg_setcolor(0);
else
fg_setcolor(1);
fg_rect(x1,x2,y1,y2);
/* move to the center of the screen */
x1 = xlimit / 2;
y1 = (ylimit + menu_bottom) / 2;
fg_move(x1,y1);
/* draw concentric circles */
x2 = 4;
fg_setcolor(15);
for (i = 0; i < 25; i++)
{
fg_circle(x2);
x2 += 8;
}
/* wait for a keystroke */
fg_mousevis(ON);
wait_for_keystroke();
/* restore clipping limits */
fg_setclip(0,fg_getmaxx(),0,fg_getmaxy());
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_clip -- do those lines, clipped to a small rectangle *
* *
\**********************************************************************/
int do_clip()
{
register int i,j;
int x1,x2,y1,y2;
int xinc;
static int lcolor[] = {2,1,9,11,11,9,1,2};
/* establish clipping limits - small rectangle in middle of screen */
fg_setclip(135,510,menu_bottom+55,ylimit-55);
/* clear bottom of screen */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_setcolor(15);
fg_rect(135,510,menu_bottom+55,ylimit-55);
/* draw horizontal lines */
fg_setcolor(0);
for (i = menu_bottom; i < ylimit; i+=40)
{
for (j = 0; j < 8; j++)
{
if (mode14 || mode16)
fg_setcolor(lcolor[j]);
y1 = i + 3*j;
fg_move(0,y1);
fg_draw(xlimit,y1);
}
}
/* draw vertical lines */
y1 = menu_bottom;
y2 = ylimit;
for (i = 0; i < 640; i+=60)
{
for (j = 0; j < 8; j++)
{
if (mode14 || mode16)
fg_setcolor(lcolor[j]);
x1 = i + 3*j;
fg_move(x1,y1);
fg_draw(x1,y2);
}
}
/* draw red diagonal lines */
y1 = menu_bottom;
y2 = ylimit;
xinc = ylimit - menu_bottom;
fg_setcolor(12);
for (x1 = -640; x1 < 640; x1+=60)
{
x2 = x1 + xinc;
fg_move(x1,y1);
fg_draw(x2,y2);
}
y1 = menu_bottom;
y2 = ylimit;
xinc = ylimit - menu_bottom;
/* draw red diagonal lines */
fg_setcolor(4);
for (x1 = 0; x1 < 1280; x1+=60)
{
x2 = x1-xinc;
fg_move(x1,y1);
fg_draw(x2,y2);
}
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* clear the screen and return to the menu */
fg_mousevis(OFF);
fg_setclip(0,fg_getmaxx(),0,fg_getmaxy());
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_ellipses -- draw a bunch of elipses *
* *
\**********************************************************************/
do_ellipses()
{
register int i;
int x1,x2,x3,y1;
/* clear the screen */
fg_mousevis(OFF);
if (mode06 || mode11)
fg_setcolor(1);
else
fg_setcolor(9);
fg_rect(0,xlimit,menu_bottom,ylimit);
/* move to the center of the screen */
x1 = xlimit / 2;
y1 = (ylimit + menu_bottom) / 2;
fg_move(x1,y1);
/* draw concentric ellipses */
x2 = 4;
x3 = 1;
fg_setcolor(0);
for (i = 0; i < 80; i++)
{
fg_ellipse(x2,x3);
x2 += 3;
x3++;
}
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_lines -- draw lines to create a plaid pattern *
* *
\**********************************************************************/
do_lines()
{
register int i,j;
int x1,x2,y1,y2;
int xinc;
static int lcolor[] = {2,1,9,11,11,9,1,2};
/* clear bottom part of screen */
fg_mousevis(OFF);
fg_setcolor(15);
fg_rect(0,xlimit,menu_bottom,ylimit);
/* draw horizontal lines */
fg_setcolor(0);
for (i = menu_bottom; i < ylimit; i+=40)
{
for (j = 0; j < 8; j++)
{
if (mode14 || mode16)
fg_setcolor(lcolor[j]);
y1 = i + 3*j;
fg_move(0,y1);
fg_draw(xlimit,y1);
}
}
/* draw vertical lines */
y1 = menu_bottom;
y2 = ylimit;
for (i = 0; i < 640; i+=60)
{
for (j = 0; j < 8; j++)
{
if (mode14 || mode16)
fg_setcolor(lcolor[j]);
x1 = i + 3*j;
fg_move(x1,y1);
fg_draw(x1,y2);
}
}
/* draw red diagonal lines */
y1 = menu_bottom;
y2 = ylimit;
xinc = ylimit - menu_bottom;
fg_setcolor(12);
for (x1 = -640; x1 < 640; x1+=60)
{
x2 = x1 + xinc;
fg_move(x1,y1);
fg_draw(x2,y2);
}
y1 = menu_bottom;
y2 = ylimit;
xinc = ylimit - menu_bottom;
/* draw red diagonal lines */
fg_setcolor(12);
for (x1 = 0; x1 < 1280; x1+=60)
{
x2 = x1 - xinc;
fg_move(x1,y1);
fg_draw(x2,y2);
}
/* wait for a keystroke or mouse button */
fg_mousevis(ON);
wait_for_keystroke();
/* restore the screen and return to the menu */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_paint -- draw a quartered circle, then paint around it *
* *
\**********************************************************************/
do_paint()
{
int x1,x2,y1,y2;
/* restor the screen */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
/* draw a rectangle */
y1 = menu_bottom + scale(20);
y2 = ylimit - scale(20);
x1 = 40;
x2 = xlimit - 40;
if (mode06 || mode11)
fg_setcolor(0);
else
fg_setcolor(11);
fg_rect(x1,x2,y1,y2);
/* outline the rectangle */
if (mode06 || mode11)
fg_setcolor(1);
else
fg_setcolor(0);
draw_box(x1,x2,y1,y2);
y1 = (ylimit + menu_bottom) / 2;
x1 = xlimit / 2;